<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    </head>
    <body>
        <div ng-controller="RegistrarIncidenciaCtrl">
            <div th:include="components/confirmation/delete"></div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-filter icon-border-left"></i><strong>Registrar Incidencias  de Control de Calidad</strong></h3>
                </div>
                <div class="container-fluid panel-body">
                    <div class="alert alert-danger" ng-show="errorResponse">
                    <strong>ERROR: {{errorResponse}}</strong></div>
                    <div>
                    <form name="frmBusqueda">
                        <fieldset class="col-md-3">
                            <div class="table-responsive">
                                <table class="table table-striped table-hover table-condensed">
                                    <thead>
                                        <tr>
                                            <td><span>C&oacute;digo Solicitud</span></td>
                                            <td><span><input type="text" ng-model="codigoSolicitud"/></span></td>
                                            <td colspan="2"><span><button type="button" class="btn btn-primary" id="btnBuscar" ng-click="buscarSolicitudes(codigoSolicitud)"><i class="fa fa-search" style="margin-right:8px; font-size:14px;"></i>Buscar</button></span></td>
                                        </tr>
                                    </thead>
                                </table>
                            </div>
                        </fieldset>
                    </form>
                    </div>
                    <div class="table-responsive">
                        <table class="table table-striped table-bordered table-hover table-condensed">
                            <thead>
                                <tr>
                                    <th><span>Solicitud</span></th>
                                    <th><span>Descripcion Corta</span></th>
                                    <th><span>Tipo</span></th>
                                    <th><span>Prioridad</span></th>
                                    <th><span>Fecha de Registro</span></th>
                                    <th class="action-col"><span></span></th>
                                </tr>
                           </thead>
                           <tbody>
                                <tr ng-repeat="solicitud in solicitudes">
                                    <td>{{solicitud.codigo}}</td>
                                    <td>{{solicitud.descripcionCorta}}</td>
                                    <td>{{solicitud.tipoSolicitud.descripcion}}</td>
                                    <td>{{obtenerDescripcionPrioridad(solicitud.prioridad)}}</td>
                                    <td>{{solicitud.fechaRegistro | date:'dd/MM/yyyy'}}</td>
                                    <td style="white-space: nowrap">
                                        <button type="button" class="btn btn-primary" id="cmdAgregarIncidencia" ng-click="agregarIncidencia()" tooltip-placement="right" tooltip="Agregar Incidencia"><i class="fa fa-plus-circle" style="margin-right:8px;"></i>Agregar Incidencia</button>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="table-responsive">
                        <table class="table table-striped table-bordered table-hover table-condensed">
                            <thead>
                                <tr>
                                    <th class="action-col"><span>Acciones</span></th>
                                    <th><span>Entregable</span></th>
                                    <th><span>Descripcion</span></th>
                                    <th><span>Tipo</span></th>
                                    <th><span>Responsable</span></th>
                                </tr>
                           </thead>
                           <tbody>
                                <tr ng-repeat="incidencia in incidencias">
                                    <td style="white-space: nowrap">
                                        <form editable-form="" name="rowform" ng-show="rowform.$visible" class="form-buttons form-inline" onbeforesave="registrarIncidencia($data, incidencia.codigo)" oncancel="cancelar($index, incidencia.codigo)" shown="inserted == incidencia">
                                            <div ng-disabled="rowform.$waiting" ng-click="rowform.$submit()" style="float:left;margin-left:5px;" class="ui-pg-div ui-inline-cancel" data-original-title="Grabar"><span class="ui-icon ui-icon-disk"></span></div>
                                            <div ng-disabled="rowform.$waiting" ng-click="rowform.$cancel()" style="float:left;margin-left:5px;" class="ui-pg-div ui-inline-cancel" data-original-title="Cancelar"><span class="ui-icon ui-icon-cancel"></span></div>
                                        </form>
                                        <div class="buttons" ng-show="!rowform.$visible">
                                            <div ng-click="rowform.$show()" style="float:left;cursor:pointer;" class="ui-pg-div ui-inline-edit" tooltip="Editar incidencia"><span class="ui-icon ui-icon-pencil"></span></div>
                                            <div ng-click="showModalDeletionConfirmation(incidencia.codigo, 'deletionConfirmationDivId', 'Incidencia: ' + incidencia.codigo)" style="float:left;margin-left:5px;" class="ui-pg-div ui-inline-del" tooltip="Eliminar incidencia"><span class="ui-icon ui-icon-trash"></span></div>
                                        </div>
                                    </td>
                                    <td><span editable-select="incidencia.entregable.codigo" e-name="codigoEntregable" e-form="rowform"
                                              e-ng-options="e.codigo as e.descripcion for e in entregables"
                                              onshow="cargarEntregables()"
                                              onbeforesave="validarSeleccionado('Entregable', $data)">{{incidencia.entregable.descripcion}}</span></td>
                                    <td><span editable-text="incidencia.descripcion" e-name="descripcion" e-form="rowform"
                                              e-maxlength="100" e-size="50" onbeforesave="validarNoVacio('Descripcion', $data)">{{incidencia.descripcion}} </span></td>
                                    <td><span editable-select="incidencia.tipoIncidencia.codigo" e-name="codigoTipoIncidencia" e-form="rowform"
                                              e-ng-options="t.codigo as t.descripcion for t in tiposIncidencia"
                                              onshow="cargarTiposIncidencia()"
                                              onbeforesave="validarSeleccionado('Tipo Incidencia', $data)">{{incidencia.tipoIncidencia.descripcion}}</span></td>
                                    <td><span editable-select="incidencia.usuario.codigo" e-name="codigoUsuario"
                                              e-ng-options="u.codigo as u.nombreCompleto for u in usuarios" e-form="rowform"
                                              onshow="cargarUsuarios()"
                                              onbeforesave="validarSeleccionado('Responsable', $data)">{{incidencia.usuario.nombreCompleto}}</span></td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>